#! /usr/bin/env python
#coding:utf-8
#
import redis
import json
import random

#请修改为自己的ip 与端口 密码
host = '127.0.0.1'
port = 6379
password = ''

#清空redis
def del_db():
	i = 1    
    	redis_conn = redis.Redis(host=host, port=port, db=i, password=password)
	data = redis_conn.keys()
	for i in data:
		user_data = redis_conn.get(i)
		user = json.loads(user_data)
		if user.has_key('coins'):
			del user['coins']
			print user, type(user)
			redis_conn.set(i,json.dumps(user))
	
	print data, type(data)
	print "更改redis的值"

del_db()
